home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 13 / AMIGAplus Sonderheft 13 (1998)(ICP)(DE)[!].iso / rexx / flushgadgets.sirexx < prev    next >
Text File  |  1997-09-10  |  2KB  |  73 lines

  1. /* This will attempt to expunge all unused Gadgets/classes from memory */
  2.  
  3. /* IMPORTANT!  Due to a bug in earlier glyph.image versions that will 
  4.                crash if it's asked to expunge itself.  Do NOT use this 
  5.                script if you have glyph.image 41.4 or older!
  6. */
  7.  
  8.  
  9. options results
  10. signal on error
  11.  
  12. address 'INSPECTOR.1'
  13.  
  14.  
  15.  
  16. /* Select the Libs list. */
  17.  
  18. GetDisplay ; currentdisplay = result
  19. If currentdisplay ~= 5 Then SetDisplay 5
  20.  
  21.  
  22. /* We don't want to be bothered with requesters */
  23.  
  24. GetPrefs Confirm ; oldconfirm = result
  25. if oldconfirm = "ON" Then SetPrefs Confirm OFF
  26.  
  27.  
  28. /* browse thru the list until we reach the last item. */
  29.  
  30. flushed = 0
  31.  
  32. counter = 0
  33.  
  34. done = 0
  35.  
  36. Do while done = 0
  37.  
  38.    SelectNode Num counter ; if result = "ERROR" then done = 1
  39.  
  40.    If done = 0 Then Do
  41.       GetNodeInfo 1 ; nodename = result
  42.  
  43.       If Pos(".gadget",nodename) >0 | Pos(".class",nodename) >0 | Pos(".image",nodename) >0 Then Do 
  44.  
  45.          SetStatus "Flushing..."
  46.          FlushNode
  47.  
  48. /* If the node is gone, then the next node was moved one level to the 
  49.    top - so our next node is on that same position.  So, we won't
  50.    move down, so next iteration will be on this bubbled-up node. */
  51.  
  52.          GetStatus ; status = result
  53.          If Pos("Flushed",status) > 0 Then Do
  54.             counter = counter - 1  /* So we do not skip the new one */
  55.             flushed = flushed + 1
  56.          End
  57.       End
  58.  
  59.       counter = counter + 1
  60.  
  61.    End
  62. End
  63.  
  64.  
  65.  
  66. /* Restore the Confirm setting */
  67.  
  68. SetPrefs Confirm oldconfirm
  69.  
  70. /* Report */
  71.  
  72. SetStatus 'Flushed '||flushed||' gadgets(s).'
  73.